package main

import "fmt"

func nodeA(n int) <-chan string {
	out := make(chan string)
	go func() {
		defer close(out)
		for i := 1; i <= n; i++ {
			out <- fmt.Sprint("节点A-", i)
		}
	}()
	return out
}

func nodeB(in <-chan string) <-chan string {
	out := make(chan string)
	go func() {
		defer close(out)
		for c := range in {
			out <- "节点B" + c
		}
	}()
	return out
}

func nodeC(in <-chan string) <-chan string {
	out := make(chan string)
	go func() {
		defer close(out)
		for c := range in {
			out <- "节点C" + c
		}
	}()
	return out
}

func main() {
	componentA := nodeA(9)
	componentB := nodeB(componentA)
	componentC := nodeC(componentB)
	for goods := range componentC {
		fmt.Println(goods)
	}
}
